import React, { Component } from "react";
//引入react-router-dom包
import { Link } from "react-router-dom";
export default class List extends Component {
    render() {
        let list = this.props.location.state;

        return (
            <div className="list">
                {list.map((item, index) => {
                    return (
                        <Link
                            to={{ pathname: "/detail", state: item.children }}
                            className="item"
                            key={item.id}
                        >
                            <img src={item.img} alt="" />
                            <span>{item.title}</span>
                        </Link>
                    );
                })}
            </div>
        );
    }
}
